package com.can.Listener;

import com.can.domain.vo.CommonVo;
import com.can.service.UserService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class UserPointsListener {

    @Autowired
    private UserService userService; // 注入Service

    @RabbitListener(queues = "exp")
    public void handleUpdatePointsMessage(String msg) {
        try{        int id=Integer.parseInt(msg);
        CommonVo result = userService.jia3(id);
        if (result.getState() == 200) {
            System.out.println("更新用户积分成功，ID是: " + id);
        }else {
            System.out.println("更新用户积分失败，ID是: " + id);
        }}catch (Exception e) {
            System.out.println("收到非法的用户ID消息: "+ msg);
        }

    }
}